package com.lagou.wwyan.dubbo.component;

import com.lagou.wwyan.service.HelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class HelloComponent {
    @Reference(timeout = 3000)
    private HelloService helloService;
    private ExecutorService executorService = Executors.newScheduledThreadPool(2000);

    public String sayHelloA(){
        String sayHelloA = helloService.sayHelloA();
//        System.out.println(sayHelloA);
        return sayHelloA;
    }
    public String sayHelloB(){
        String sayHelloB = helloService.sayHelloB();
//        System.out.println(sayHelloB);
        return sayHelloB;
    }
    public String sayHelloC(){
        String sayHelloC = helloService.sayHelloC();
//        System.out.println(sayHelloC);
        return sayHelloC;
    }

    public void sayHello(){
        executorService.execute(this::sayHelloA);
        executorService.execute(this::sayHelloB);
        executorService.execute(this::sayHelloC);
    }
}
